#ifndef OPENGLCANVAS_H
#define OPENGLCANVAS_H

#include <QObject>
#include <QWidget>
#include <QGLWidget>
#include <vector>
#include <QMouseEvent>
#include "stlmodel.h"
#include<QtCore/QObject>
#include <QList>

class OpenglCanvas : public QGLWidget, protected QOpenGLFunctions_3_3_Core
{
    Q_OBJECT
public:
    OpenglCanvas(QWidget *);
    void SetLookPos(float,float,float);
    ~OpenglCanvas();
    Stlmodel mLink1;
    Stlmodel mLink2;
    Stlmodel mLink3;
    Stlmodel mLink4;
    Stlmodel mLink5;
//    Stlmodel mLink6;
    QList<double> mInvTheta;

    void InverseKinemathic();
    QList<double> InverseTheta();

protected:
    void initializeGL();
    void paintGL();
    void resizeGL(int width, int height);
    bool event(QEvent *) ;

signals:
    void InverseKinematicDone();
public slots:
    void setPitch(double pitch);
    void setYaw(double yaw);
    void setDistance(double distance);
    void OnThetaChangeAngle(float,float,float,float,float,float);
    void wheelEvent(QWheelEvent *event);


private:
    GLuint mVBO, mVAO, mEBO;
    QOpenGLShaderProgram mShaderProgram;
    GLuint programId;

    void setView();
    bool mMousePressed;
    int w, h;
    double mPitch, mYaw, mDistance;

    float mLookx,mLooky,mLookz;
};

#endif // OPENGLCANVAS_H
